package com.esri.core.geometry;

import com.esri.core.internal.util.d;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class ProjectionTransformation {
    private SpatialReference a;
    private SpatialReference b;
    private CompositeGeographicTransformation c;

    private ProjectionTransformation() {
    }

    public static ProjectionTransformation create(SpatialReference spatialReference, SpatialReference spatialReference2, CompositeGeographicTransformation compositeGeographicTransformation) {
        if (spatialReference == null || spatialReference2 == null || compositeGeographicTransformation == null) {
            throw new IllegalArgumentException("Input to create projection transformation cannot be null.");
        }
        ProjectionTransformation projectionTransformation = new ProjectionTransformation();
        projectionTransformation.a = spatialReference;
        projectionTransformation.b = spatialReference2;
        projectionTransformation.c = compositeGeographicTransformation;
        return projectionTransformation;
    }

    public SpatialReference getInputSR() {
        return this.a;
    }

    public SpatialReference getOutputSR() {
        return this.b;
    }

    public CompositeGeographicTransformation getGeoTransformation() {
        return this.c;
    }

    public String toJson() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        sb.append("\"srIn\":" + this.a.toJson() + ",");
        sb.append("\"srOut\":" + this.b.toJson() + ",");
        StringBuilder sb2 = new StringBuilder();
        sb2.append("\"geoTransformations\":");
        CompositeGeographicTransformation compositeGeographicTransformation = this.c;
        sb2.append(compositeGeographicTransformation == null ? null : compositeGeographicTransformation.a());
        sb.append(sb2.toString());
        sb.append("}");
        return sb.toString();
    }

    public static ProjectionTransformation fromJson(String str) throws Exception {
        JsonParser c = d.c(str);
        if (d.c(c)) {
            ProjectionTransformation projectionTransformation = new ProjectionTransformation();
            while (c.nextToken() != JsonToken.END_OBJECT) {
                String currentName = c.getCurrentName();
                if ("srIn".equals(currentName)) {
                    projectionTransformation.a = SpatialReference.fromJson(c);
                } else if ("srOut".equals(currentName)) {
                    projectionTransformation.b = SpatialReference.fromJson(c);
                } else if ("geoTransformations".equals(currentName)) {
                    projectionTransformation.c = CompositeGeographicTransformation.a(c);
                } else {
                    c.skipChildren();
                }
            }
            c.close();
            return projectionTransformation;
        }
        return null;
    }
}
